/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sdc.strategy.allocation;

import java.util.LinkedList;
import java.util.List;
import sdc.Address;
import sdc.ServiceBroker;
import sdc.component.type.ComponentType;
import sdc.net.server.comp.ComponentServer;
import sdc.net.server.comp.ComponentServerManager;

/**
 *
 * @author yokoe
 */
public class FillInAllocateStrategy extends AllocateStrategy{

	@Override
	public List<ComponentServer> allocateComponents(ComponentType type, int duplicateNum)
	{
		List<Address> addresses = ServiceBroker.INSTANCE.getFreshAddresses(duplicateNum);

		List<ComponentServer> componentServers = new LinkedList<ComponentServer>();

		for(Address address : addresses)
		{
			ComponentServer componentServer = ComponentServerManager.INSTANCE.get(address);

			allocateComponentToServer(componentServer, type);

			componentServers.add(componentServer);
		}

		return componentServers;
	}
}
